home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 5
/
Amiga Tools 5.iso
/
tools
/
developer-tools
/
andere sprachen
/
gamesmaster
/
demosrc
/
sprites.s
< prev
next >
Wrap
Text File
|
1996-07-16
|
5KB
|
149 lines
;Sprite example
;--------------
;This example shows you how to set up a 16 colour OCS sprite with a doubled
;X axis (32 pixels width). Those with hardware experience will know that it
;takes 4 sprite banks to do this successfully in OCS, which leaves you with
;another 4 banks to do with what you will.
;
;Notice that the screen is only 1 bitplane large, even though the sprite is
;16 colours. This is because the sprite is independent of the screen
;bitmap. You can access colours not in the screen by setting up a large
;palette and specifying the amount of colours in SS_AmtColours (in this
;case, we set 32 colours to access the sprite colour bank).
;
;Also, try moving the sprite around a bit with the mouse.
opt o+
INCLUDE "exec/exec_lib.i"
INCLUDE "games/games_lib.i"
INCLUDE "games/games.i"
INCLUDE "games/gamesbase.i"
CALL MACRO
jsr _LVO\1(a6)
ENDM
SECTION "Sprites",CODE
;===========================================================================;
; INITIALISE DEMO
;===========================================================================;
Start: MOVEM.L A0-A6/D1-D7,-(SP)
move.l ($4).w,a6
lea GMS_Name(pc),a1
moveq #$00,d0
CALL OpenLibrary
move.l d0,GMS_Base
beq.s Error
move.l GMS_Base(pc),a6 ;Run this demo at a user-selected
CALL SetUserPri ;priority.
lea ScreenStruct(pc),a0 ;Initialise our screen for use.
CALL Add_Screen
tst.l d0
bne.s Error
CALL Show_Screen ;Show our screen.
lea SparkieStruct(pc),a1
CALL Init_Sprite
CALL Update_Sprite ;First get him onto the screen.
;===========================================================================;
; MAIN LOOP
;===========================================================================;
Loop: addq.w #1,d7 ;Animation/Frame delay, so that
btst #0,d7 ; our anim does not run too fast!
beq.s .Mouse
cmp.w #5,SPR_Frame(a1) ;Do the animation for the sprite.
beq.s .reset ;(simply by increasing the frame
addq.w #1,SPR_Frame(a1) ; number).
bra.s .Mouse
.reset clr.w SPR_Frame(a1)
.Mouse moveq #JPORT1,d0 ;Read from port 1
CALL Read_Mouse ;Go get mouse position.
move.l d0,SPR_XPos(a1) ;Update the X/Y positions in one go.
CALL Wait_OSVBL ;Allow screen-switching.
CALL Update_Sprite ;Put Sparkie on the screen.
btst #M_LMB,MouseButtons1+1(a6)
beq.s Loop
;===========================================================================;
; RETURN TO DOS
;===========================================================================;
.done CALL Delete_Screen ;Give back screen memory etc.
Error move.l GMS_Base(pc),a1
move.l ($4).w,a6
CALL CloseLibrary
Quit MOVEM.L (SP)+,A0-A6/D1-D7
moveq #$00,d0
rts
;===========================================================================;
; DATA
;===========================================================================;
GMS_Name:
dc.b "games.library",0
even
GMS_Base:
dc.l 0
SparkieStruct:
dc.w 0 ;Number 0.
dc.l Gfx_Sparkie ;Ptr to graphic.
dc.w 100,100 ;Beginning X/Y position
dc.w 0 ;Current frame.
dc.w 16 ;Width (16/32/64)
dc.w 21 ;Height
dc.w 16 ;Amt of colours.
dc.w 16 ;Colour start in palette.
dc.w 4 ;Amt of planes.
dc.w SPR_OCS|LORES|XLONG ;Attributes.
dc.l 0,0,0,0 ;Private.
AMT_PLANES = 1
ScreenStruct:
dc.l "GSV1"
dc.l 0,0,0 ;Screen_Mem1/2/3
dc.l 0 ;Screen link.
dc.l ScreenPalette ;Address of the screen palette.
dc.l 0 ;Address of a ColourList.
dc.l 32 ;Amt of colours in the palette.
dc.w 256,320,320/8 ;Screen Height, Width, Width/8
dc.w 256,320,320/8 ;Pic Height, Width, Width/8
dc.w AMT_PLANES ;Amt_Planes
dc.w 0,0 ;Top Of Screen, X/Y
dc.w 0 ;Scroll buffer in pixels/8.
dc.w 0,0 ;X/Y counters (for scrolling).
dc.l NOBURST|SPRITES|NOSPRBDR ;Special attributes.
dc.w LORES ;Screen mode.
dc.b INTERLEAVED ;Screen type
dc.b 0 ;Screen Is Being Displayed?
dc.l 0,0 ;Reserved area.
even
ScreenPalette:
dc.w $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
dc.w $0000,$0688,$0466,$0344,$0CC0,$0980,$0870,$0650
dc.w $01C2,$0050,$0B0B,$0606,$0F20,$0910,$0BBB,$0FFF
dc.w $00BF,$0068,$0568,$09BF,$0FF0,$0EE0,$0BA0,$0540
;===========================================================================;
; ALL CHIP RAM DATA HERE
;===========================================================================;
SECTION "Graphics",DATA_C
Gfx_Sparkie:
INCBIN "GAMESLIB:Store/Sparkie.raw"